<?php

namespace App\Console\Commands;

use App\Models\Sign;
use Illuminate\Console\Command;

class BrokenSignMonitor extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:name';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $today=strtotime(date('Y-m-d'));//今天开始的时间
        //查询的数据如果上一次签到时间比今天小就说明没签到
        //假设今天已经签到  我要更改的是今天未签到的数据把它连续签到的次数修改为0然后就到第二天了
        $data=Sign::where('last_sign_time','<',$today)->where('max_continuity','>',0)->get(); //查询出今天未签到的数据 根据id将其连续签到的时间为
        foreach ($data as $val){
            Sign::where('sign_id',$val->sign_id)->update(['max_continuity'=>0]);//今天未签到的的把连续签到次数修改为0
        }

    }
}
